<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/com/include/declare.jspf" %>
<%-- 
    JSP Name : counsel_calendar03.jsp
    Description : 예약일정 조회
    author SJYoon
    since 2012. 6. 25.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 6. 25.     SJYoon     최초 생성
--%>
<!-- 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
</head>
 -->
<body>
                                <input type="hidden" name="strtYmd" id="strtYmd" value="${testDriveVO.strtYmd }"  />
                                <input type="hidden" name="std" id="std" value="${testDriveVO.std }"  />
                                <input type="hidden" name="etd" id="etd" value="${testDriveVO.etd }"  />                                
                                <div class="month-select">
                                    <div class="month">
                                        <em class="m-txt">${fn:substring(testDriveVO.strtYmd,4,6) }</em>
                                        <img src="/kr/images/counsel/txt_month.gif" alt="월" />             
                                        <a href="javascript:preMonth();"><img src="/kr/images/common/button/btn_month_prev.gif" alt="이전달" class="prev"  /></a>
                                        <a href="javascript:nextMonth();"><img src="/kr/images/common/button/btn_month_next.gif" alt="다음달" class="next"  /></a>
                                    </div>
                                    <p class="example"><img src="/kr/images/counsel/img_example.gif" alt="범례 이미지" /></p>
                                </div>
                                <table class="calendar" summary="시승가능일자 및 시간 선택 기능">
                                <caption>시승가능일자 및 시간표</caption>
                                <thead>
                                <tr>
                                <c:forEach var="i" begin="0" end="6" >
                                    <c:choose>
                                        <c:when test="${!empty testDriveVO.dateWeek }">
                                            <c:if test="${!empty testDriveVO.dateWeek[i] }">
                                    <th scope="col">${testDriveVO.dateWeek[i] }</th>
                                            </c:if>
                                        </c:when>
                                    </c:choose>               
                                </c:forEach>
                                </tr>
                                </thead>
                                <tbody>
                                
                                <fmt:parseNumber var="wd"> ${testDriveVO.firstDaysWeek -1 }</fmt:parseNumber>
                                <c:set var="t" scope="page" value="1"></c:set>
                                <c:if test="${ (testDriveVO.firstDaysWeek + testDriveVO.lastDay -1 ) > 35 }"><c:set var="w" scope="page" value="42"></c:set></c:if>
                                <c:if test="${ (testDriveVO.firstDaysWeek + testDriveVO.lastDay -1 ) <= 35 }"><c:set var="w" scope="page" value="35"></c:set></c:if>
                                <c:forEach var="j" begin="1" end="${w-wd }" >
                                    <c:if test="${t % 7 == 1}" >
                                <tr>
                                    </c:if>                                    
                                    <c:if test="${ j == 1 }">
                                    <c:forEach var="td" begin="1" end="${wd}" step="1">
                                        <td></td>
                                        <c:set var="t" scope="page" value="${t+1 }"></c:set>
                                    </c:forEach>
                                    </c:if>
                                    <c:choose>
                                        <c:when test="${testDriveVO.todate == calenderList[(j-1)*4].nowDay}"><td id="daytd${j }" class="today"></c:when>
                                        <c:when test="${testDriveVO.todate+2 > calenderList[(j-1)*4].nowDay && testDriveVO.todate != calenderList[(j-1)*4].nowDay}"><td id="daytd${j }" ></c:when>
                                        <c:otherwise><td id="daytd${j }" ></c:otherwise>
                                    </c:choose>
                                        <div class="daywrap">
                                            <p class="txt-today">TODAY</p>
                                            <c:if test="${ testDriveVO.lastDay >= j }">
                                            <p class="day"><c:out value="${ j }"/>일  </p>
                                            </c:if>
                                            <div class="select-time">
                                            <c:forEach var="i" begin="0" end="3">
                                                <fmt:parseNumber var="Nday">${calenderList[(j-1)*4+i].nowDay }</fmt:parseNumber>
                                                <fmt:parseNumber var="Tday">${testDriveVO.todate }</fmt:parseNumber>
                                                <fmt:parseNumber var="Time">${fn:substring(testDriveVO.dayTime,8,10) }</fmt:parseNumber>
                                                <fmt:parseNumber var="Std">${testDriveVO.std }</fmt:parseNumber>
                                                <fmt:parseNumber var="Etd">${testDriveVO.etd }</fmt:parseNumber>
                                                <c:choose>
                                                    <c:when test="${calenderList[(j-1)*4+i].schuseYn == 'N'}">
                                                        <button class="disabled" disabled="disabled">
                                                    </c:when>
                                                    <c:when test="${Nday <= Tday}">
                                                        <button class="disabled" disabled="disabled">
                                                    </c:when>
                                                    <c:when test="${ Nday < Std}">
                                                        <button class="disabled" disabled="disabled">
                                                    </c:when>
                                                    <c:when test="${Nday > Tday && Nday <= Etd }">
                                                        <c:if test="${Usbl[(j-1)*4+i].usblcpsn > calenderList[(j-1)*4+i].tsrdUsblCarCrt}">
                                                        <c:if test="${empty calenderList[(j-1)*4+i].carCd }">
                                                            <c:if test="${Nday < (Tday+2) && Time <= 12 }"><button onclick="javascript:selectDay('${Tday}','${Nday}','${j}','${calenderList[(j-1)*4+i].prcttime }');" ></c:if>
                                                            <c:if test="${Nday < (Tday+2) && Time > 12 }"><button class="disabled" disabled="disabled"></c:if>
                                                            <c:if test="${Nday > Tday+1 }"><button onclick="javascript:selectDay('${Tday}','${Nday}','${j}','${calenderList[(j-1)*4+i].prcttime }');" ></c:if>
                                                        </c:if>
                                                        </c:if>
                                                        <c:if test="${not empty calenderList[(j-1)*4+i].carCd || Usbl[(j-1)*4+i].usblcpsn <= calenderList[(j-1)*4+i].tsrdUsblCarCrt}">
                                                            <button class="disabled" disabled="disabled">
                                                        </c:if>
                                                    </c:when>
                                                    <c:when test="${Nday > Tday && Nday > Etd}">
                                                        <button class="disabled" disabled="disabled">
                                                    </c:when>
                                                    <c:when test="${empty Std || empty Etd}">
                                                        <button class="disabled" disabled="disabled">
                                                    </c:when>
                                                </c:choose>
                                                <c:choose>
                                                    <c:when test="${calenderList[(j-1)*4+i].prcttime =='10'}"> <span>10시</span></c:when>
                                                    <c:when test="${calenderList[(j-1)*4+i].prcttime =='12'}"> <span>12시</span></c:when>
                                                    <c:when test="${calenderList[(j-1)*4+i].prcttime =='14'}"> <span>14시</span></c:when>
                                                    <c:when test="${calenderList[(j-1)*4+i].prcttime =='16'}"> <span>16시</span></c:when>
                                                </c:choose>
                                                </button>
                                            </c:forEach>
                                            </div>
                                        </div>
                                    </td>

                                <c:if test="${ t % 7 == 0 }">
                                </tr>       
                                </c:if>
                                <c:set var="t" scope="page" value="${t+1 }"></c:set>
                                </c:forEach>
                                
                                </tbody>
                                </table>
</body>           
</html>                                                     